package com.example.tb.controller;

import com.example.tb.entity.BiOpeningRecord;
import com.example.tb.service.BiOpeningRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.io.File;
import java.util.ArrayList;

@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {

    @Resource
    private BiOpeningRecordService biOpeningRecordService;

//    public static void main(String[] args) {
//        String fileName = "D:/dev/TB/前期/开标记录-国网浙江省电力有限公司2024年第一次物资公开招标采购.xlsx";
//        EasyExcel.read(fileName, BiOpeningRecord.class, new TestUtils()).sheet().headRowNumber(3).doRead();
//        // 如果excel是多行表头比如说2行，需要设置行头数headRowNumber，默认不设置为1行表头，sheet不传默认读取第一个sheet
////        EasyExcel.read(fileName, User.class, new UserExcelListener()).sheet().headRowNumber(2).doRead();
//    }


//    @GetMapping("/test")
//    public String test() {
////        ExcelResolveUtils utils = new ExcelResolveUtils();
//        File f1 = new File("D:/dev/TB/前期/国网西藏电力有限公司2024年第一次物资公开招标采购项目推荐的中标候选人公示.xlsx");
//        try {
//            ArrayList<BiOpeningRecord> arrayList = biOpeningRecordService.readExcel(f1);
////            ArrayList<BiOpeningRecord> arrayList = utils.readExcel(f1);
//            System.out.println(arrayList);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return "OK";
//    }
//
//
//
//
//    @GetMapping("/test1")
//    public String test1() {
//        ArrayList<String> objects = new ArrayList<>();
//        File file = new File("D:/dev/TB/test");
//        ArrayList<String> filename = biOpeningRecordService.traversalFile(file);
//        for (int i = 0; i < filename.size(); i++) {
//            try {
//                File f1 = new File(filename.get(i));
//                System.out.println(f1);
////                ArrayList<BiOpeningRecord> arrayList = biOpeningRecordService.readExcel(f1);
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//        }
//        return "OK";
//    }




    @GetMapping("/test2")
    public String test2() {
        ArrayList<String> objects = new ArrayList<>();
        File file = new File("D:/dev/未读xls文件");
        ArrayList<String> filename = biOpeningRecordService.traversalFile(file);
        for (int i = 0; i < filename.size(); i++) {
            try {
                File f1 = new File(filename.get(i));
                System.out.println(f1);
                ArrayList<BiOpeningRecord> arrayList = biOpeningRecordService.readExcel(f1);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return "OK";
    }


}